<style type="text/css">
	#invAlertBox .dialog-content{ padding:0; border-top:1px solid #FFF;background:#F0F0F0}
	#invAlertBox .inv-box{ background:#F0F0F0}
	#invAlertBox .inv-box  .sms-email-box{ width:550px}
	#invAlertBox .inv-box .field{ width:100%; font-size:12px; padding:0}
	#invAlertBox .inv-box .field label{ width:auto; padding-right:0}
	#invAlertBox .inv-box .field input{ margin-top:2px; *margin-top:-1px;;float:left;}
	#invAlertBox .inv-box .field .status label{*margin-top:2px;padding-right:8px; font-weight:bolder; font-size:12px;height:auto;line-height:normal!important; color:#666}
	#invAlertBox .inv-box .tit{width:50px; text-align:right; color:#333 ;padding-right:5px;}
	#invAlertBox .inv-box .box{ width:490px}
	#invAlertBox .inv-box .res_inv_invter_area{
		width: 98%;
		height: 40px;
		border: 1px solid;
		border-color: #7C7C7C #C4C4C4 #C3C3C3 #9C9C9C;
		background-color: white;
		cursor: text;
		overflow:auto;
		text-align:left;
		padding:2px
	}
	#invAlertBox .inv-box .res_inv_invter_area input{ background:none; border:none;outline: 0;}
	#invAlertBox .inv-box .res_inv_invter_area_cur{background-color: #FDFAE8;}
	#invAlertBox .inv-box .inv-msg-box{width: 98%;height: 135px;border: 1px solid;border-color: #999 #C3C3C3 #C3C3C3 #9A9A9A;padding:2px; font-size:12px}
	#invTelListBox span,#invEmailListBox span{line-height: 1.4; display:inline-block;border: 1px solid white;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: default;font-size: 12px;
font-family: Arial,sans-serif;float:left; margin-right:3px}
    #invTelListBox input,#invEmailListBox input{padding:0; margin:0; font-family: Arial,sans-serif;line-height: 1.4; display:inline-block; float:left;background:none; border:none;outline: 0;}
	#invTelListBox .err,#invEmailListBox .err{ color:#F30; border-color:#f30!important}
	#invTelListBox span.cur,#invEmailListBox span.cur{border-color: #C9C9C9;background-color: #F0F0F0;}
	#invTelListBox span.focus,#invEmailListBox span.focus{border-color: #6FB32D;background-color: #B3D199;}
	#invAlertBox .contact{ border:1px solid #ddd; width:213px;height:200px; margin-top:38px; background:#fff}
	#invAlertBox .c-tit{color:#000; border:1px solid #E1E1E1; background:#F5F5F5; font-size:12px; padding:0 5px; height:20px; line-height:20px;}
	#invAlertBox .c-tit a{color:#666}
	#invAlertBox .c-box{ color:#4a4a4a; height:168px; overflow:auto; font-size:12px; padding:5px 8px}
	#invAlertBox .c-box .t{ cursor:pointer; background:url({$TMPL}/images/ctat_u.gif) no-repeat 0 2px; padding-left:14px}
	#invAlertBox .c-box .t_cur{ background-position:0 -20px;}
	#invAlertBox .c-box a{ color:#5E5E5E; text-decoration:none;}
	#invAlertBox .c-box a.c{ display:inline-block; width:120px}
	#invAlertBox .c-box a.fs{ font-family:Tahoma; font-size:12px}
	#invAlertBox .c-box .v{display:none;}
	#invAlertBox .c-box ul{color:#5E5E5E; padding-left:10px; font-size:12px}
	#invAlertBox .c-box ul li{ padding:1px 5px; line-height:normal;}
	#invAlertBox .c-tmpbox{ font-size:12px; color:#353535; margin-left:528px; margin-top:58px; border:1px solid #CCC; background:#fff; height:160px; z-index:1000; width:225px; padding:5px;}
	#invAlertBox .c-tmpbox .c-t{ width:50px; text-align:right; padding-right:5px;}
	
</style>
<div class="inv-box p5 clearfix">
	<div class="sms-email-box f_l clearfix">
		<div class="sms-box">
			<div class="field">
				<div class="tit f_l">类型</div>
				<div class="box status f_l">
					<input type="radio" id="inv_sms_type_1" name="inv_sms_type" value="1" {if $order.order_sms_type eq 1 || $order.order_sms_typee eq 0}checked="checked"{/if} />
					<label for="inv_sms_type_1">商务{if $order.deal_type eq 0}宴请{else}邀请{/if}</label>
					<input type="radio" id="inv_sms_type_2" name="inv_sms_type" value="2" {if $order.order_sms_type eq 2}checked="checked"{/if} />
					<label for="inv_sms_type_2">朋友聚会</label>
					<input type="radio" id="inv_sms_type_3" name="inv_sms_type" value="3" {if $order.order_sms_type eq 3}checked="checked"{/if} />
					<label for="inv_sms_type_3">家庭聚会</label>
					<input type="radio" id="inv_sms_type_4" name="inv_sms_type" value="4" {if $order.order_sms_type eq 4}checked="checked"{/if} />
					<label for="inv_sms_type_4">情侣约会</label>
					{if $order.deal_type eq 0}
					<input type="radio" id="inv_sms_type_5" name="inv_sms_type" value="5" {if $order.order_sms_type eq 5}checked="checked"{/if} />
					<label for="inv_sms_type_5">随便吃吃</label>
					{/if}
				</div>
			</div>
			<div class="field">
				<div class="tit f_l">收件人</div>
				<div class="box f_l">
					<div class="res_inv_invter_area">
						<div id="invTelListBox" class="f_l" title="双击编辑">
							{foreach from=$order.order_sms_tel_list key=key item=item}
							{if $item}
							<span data-index="{$key}">{$item};</span>
							{/if}
							{/foreach}
						</div>
						<input type="text" value="" title="直接输入手机号（多个联系人分号分开）或点击右侧的手机联系人添加" name="invIptBox" />
					</div>
				</div>
			</div>
			<div class="field">
				<div class="tit f_l">正文</div>
				<div class="box f_l">
					<textarea name="msg_box" class="area inv-msg-box">{$order.order_sms_message}</textarea>
				</div>
			</div>
		</div>
		<div class="email-box hide">
			<div class="field">
				<div class="tit f_l">类型</div>
				<div class="box status f_l">
					<input type="radio" id="inv_email_type_1" name="inv_email_type" value="1" {if $order.order_email_type eq 1 || $order.order_email_type eq 0}checked="checked"{/if} />
					<label for="inv_email_type_1">商务{if $order.deal_type eq 0}宴请{else}邀请{/if}</label>
					<input type="radio" id="inv_email_type_2" name="inv_email_type" value="2" {if $order.order_email_type eq 2}checked="checked"{/if} />
					<label for="inv_email_type_2">朋友聚会</label>
					<input type="radio" id="inv_email_type_3"  name="inv_email_type" value="3" {if $order.order_email_type eq 3}checked="checked"{/if} />
					<label for="inv_email_type_3">家庭聚会</label>
					<input type="radio" id="inv_email_type_4"  name="inv_email_type" value="4" {if $order.order_email_type eq 4}checked="checked"{/if} />
					<label for="inv_email_type_4">情侣约会</label>
					{if $order.deal_type eq 0}
					<input type="radio" id="inv_email_type_5"  name="inv_email_type" value="5" {if $order.order_email_type eq 5}checked="checked"{/if} />
					<label for="inv_email_type_5">随便吃吃</label>
					{/if}
				</div>
			</div>
			<div class="field">
				<div class="tit f_l">收件人</div>
				<div class="box f_l">
					<div class="res_inv_invter_area">
						<div id="invEmailListBox" class="f_l" title="双击编辑">
							{foreach from=$order.order_email_address_list key=key item=item}
							{if $item}
							<span data-index="{$key}">{$item};</span>
							{/if}
							{/foreach}
						</div>
						<input type="text" value="" title="直接输入邮箱（多个联系人分号分开）或点击右侧的手机联系人添加" name="invIptBox" />
					</div>
				</div>
			</div>
			<div class="field">
				<div class="tit f_l">正文</div>
				<div class="box f_l">
					<textarea name="msg_box" class="area inv-msg-box">{$order.order_email_message}</textarea>
				</div>
			</div>
		</div>
		<div class="blank1"></div>
		<div class="clearfix" style="padding-left:55px">
			<span class="f_r g6 mr5"><span id="invCurrentLetters" class="">45</span>/<span id="invTotalLetters">130</span></span>
			<span class="grebtn f14 f_l">
	            <i class="green_line" style="width:155px"></i>
	            <strong class="grebtn_in" style="width:153px"><a href="javascript:" id="msgInviteBtn" class="grebtn_bg" data-url="/shop/postajax/OrderInvitation.aspx">保存并发送</a></strong>
	            <i class="green_line" style="width:155px"></i>
	        </span>
			<span class="f_l mt5 ml10 g9">(请柬将在预订成功后自动发送)</span>
		</div>
	</div>
	<div class="contact f_l">
		<div class="c-tit clearfix">
			<span class="f_l">联系人</span>
			{if  $user_info.id gt 0 }<a href="javascript:void(0)" class="f_r" onclick="ViewContactBox(this,0);">+新建联系人</a>{/if}
		</div>
		<div class="c-box">
			{$contacter_html}
		</div>
	</div>

<div class="c-tmpbox abs hide" id="contacter-tmpbox">
	<form action="{url x="store" r="order#add_contact"}">
		<div class="blank">姓名</div>
		<div class="c-t f_l">姓名</div>
		<div class="c-b f_l"><input type="text" value="" name="user_name" /></div>
		
		<div class="blank1"></div>
		<div class="c-t f_l">手机号 </div>
		<div class="c-b f_l"><input type="text" value="" name="tel" /></div>
		
		<div class="blank1"></div>
		<div class="c-t f_l">E-mail</div>
		<div class="c-b f_l"><input type="text" value="" name="email" /></div>
		<div class="blank1"></div>
		<div class="c-t f_l">&nbsp;</div>
		<div class="c-b f_l">
			<input type="checkbox" id="ct_is_close" value="1" checked="checked" name="is_close" />
			<label for="ct_is_close" id="ct_is_close_tip">新建成功后关闭该弹出框</label>
		</div>
		<div class="blank"></div>
		<div class="c-t f_l">&nbsp;</div>
		<div class="c-b f_l">
			<span class="grebtn grebtn_s mr5" style="line-height:1.4">
                <i class="green_line" style="width:50px"></i>
                <strong class="grebtn_in">
                <a href="javascript:void(0);"  id="ct_submit_btn">确定</a></strong>
                <i class="green_line" style="width:50px"></i>
            </span>
			<a href="javascript:void(0);" id="ct_close_btn" class="gray_s_btn">取消</a>
			<input type="hidden" id="ct_info_id" value="0" name="id" />
		</div>
	</form>
</div>
<div class="blank1"></div>
</div>
<script type="text/javascript">
	var is_email = false;
	var is_click_edit = false;
	var type_tip = [];
	type_tip[1] = "{$order.order_name}诚邀您莅临{$order.address}的{$order.location_name}，{$order.order_time_format}，恭候尊驾！";
	type_tip[2] = "{$order.order_name}已订{$order.order_time_format}{$order.address}的{$order.location_name}，一起happy！";
	type_tip[3] = "{$order.order_time_format}，{$order.order_name}在{$order.address}的{$order.location_name}，和您欢乐一家亲！";
	type_tip[4] = "亲，{$order.location_name}的位子终于搞定，{$order.order_time_format}{$order.address}，等你！ ";
	type_tip[5] = "{$order.order_time_format}{$order.address}的{$order.location_name}，{$order.order_name}邀您粗茶淡饭，别穿皮草！ ";
	jQuery(function(){
		initClickFunc();
		$("#invAlertBox .lb_tab li").click(function(){
			$("#invAlertBox .lb_tab li").removeClass("c");
			$(this).addClass("c");
			var f = $(this).attr("f");
			$("#invAlertBox .sms-box").addClass("hide");
			$("#invAlertBox .email-box").addClass("hide");
			if(f=="sms"){
				$("#invAlertBox .sms-box").removeClass("hide");
				is_email = false;
				$("#invAlertBox .s-list").show();
				$("#invAlertBox .e-list").hide();
				checkInvMsgLen(".sms-box",0);
			}
			else{
				$("#invAlertBox .email-box").removeClass("hide");
				is_email = true;
				$("#invAlertBox .c-box .s-list").hide();
				$("#invAlertBox .c-box .e-list").show();
				checkInvMsgLen(".email-box",1);
			}
		});
		{if !$order.order_sms_message}
		$(".sms-box .inv-msg-box").val(type_tip[1]);
		{/if}
		{if !$order.order_email_message}
		$(".email-box .inv-msg-box").val(type_tip[1]);
		{/if}
		$("input[name='inv_sms_type'],input[name='inv_email_type']").change(function(){
			$(this).parent().parent().parent().find(".inv-msg-box").val(type_tip[$(this).val()]);
			if(!is_email){
				checkInvMsgLen(".sms-box",0);
			}
			else{
				checkInvMsgLen(".email-box",1);
			}
		});
		if(!is_email){
			$("#invAlertBox .c-box .s-list").show();
			$("#invAlertBox .c-box .e-list").hide();
		}
		else{
			$("#invAlertBox .c-box .s-list").hide();
			$("#invAlertBox .c-box .e-list").show();
		}
		
		checkInvMsgLen(".sms-box",0);
		
		var is_check=false;
		$(".res_inv_invter_area").click(function(){
			is_check = false;
			$(this).addClass("res_inv_invter_area_cur");
			if (!is_check) {
				$("#invTelListBox span").removeClass("focus");
				$(this).find("input[name='invIptBox']").focus();
			}
			return false;
		});
		
		$("input[name='invIptBox']").bind("blur",function(){
			$(".res_inv_invter_area").removeClass("res_inv_invter_area_cur");
			var obj = $(this);
			var html = $.trim(obj.val());
			if (html != "") {
				if (html.indexOf(";") == -1) {
					html += ";";
				}
				if(is_email)
				{
					$("#invEmailListBox").html($("#invEmailListBox").html()+"<span data-index='"+$("#invEmailListBox span").length+"'>"+html+"</span>");
					checkSpan("#invEmailListBox",1);
				}
				else{
					$("#invTelListBox").html($("#invTelListBox").html()+"<span data-index='"+$("#invTelListBox span").length+"'>"+html+"</span>");
					checkSpan("#invTelListBox",0);
				}
				setEditBox();
				obj.val("");
			}
			return false;
		});
		$("input[name='invIptBox']").bind("keydown",function(e){
			var key = e.which;
            if (key == 13 || key == 186) {
				var obj = $(this);
				var html = $.trim(obj.val());
				if (html != "") {
					if (html.indexOf(";") == -1) {
						html += ";";
					}
					if (is_email) {
						$("#invEmailListBox").html($("#invEmailListBox").html()+"<span data-index='"+$("#invEmailListBox span").length+"'>" + html + "</span>");
						checkSpan("#invEmailListBox", 1);
					}
					else {
						$("#invTelListBox").html($("#invTelListBox").html()+"<span data-index='"+$("#invTelListBox span").length+"'>" + html + "</span>");
						checkSpan("#invTelListBox", 0);
					}
				}
				setEditBox();
				obj.val("");
				return false;
			}
		});
		
		
		$("input[name='invIptBox']").bind("keydown",function(e){
			var key = e.which;
            if (key == 8) {
				if($(this).val()==""){
					if (is_email) {
						$("#invEmailListBox span:last").remove();
					}
					else{
						$("#invTelListBox span:last").remove();
					}
				}
			}
		});
		
		$("#msgInviteBtn").click(function(){
			var tel_list = "";
			var email_list = "";
			$("#invTelListBox span").each(function(){
				if(!$(this).hasClass("err")){
					tel_list +=$(this).html();
				}
			});
			$("#invEmailListBox span").each(function(){
				if(!$(this).hasClass("err")){
					email_list +=$(this).html();
				}
			});
			
			if(tel_list!=""){
				if($.trim($("#invAlertBox .sms-box .inv-msg-box").val())=="")
				{
					alert("请输入短信正文!");
					return false;
				}
			}
			if(email_list!=""){
				if($.trim($("#invAlertBox .email-box .inv-msg-box").val())=="")
				{
					alert("请输入邮件正文!");
					return false;
				}
			}
			var query = new Object();
			query.order_id = order_id;
			query.tel = tel_list;
			query.email = email_list;
			query.sms_type = $("#invAlertBox input[name='inv_sms_type']:checked").val();
			query.email_type = $("#invAlertBox input[name='inv_email_type']:checked").val();
			query.sms_message = $.trim($("#invAlertBox .sms-box .inv-msg-box").val());
			query.email_message = $.trim($("#invAlertBox .email-box .inv-msg-box").val());
			
			$.ajax({
				url:APP_ROOT+"/store.php?ctl=order&act=sms_email_msg",
				data:query,
				type:'post',
				dataType:"json",
				cache:false,
				success:function(result){
					if(result.status==1)
					{
						$.showSuccess("邀请成功，订单确认后将会发送到你所邀请的人的手机号码或邮箱上面！");
					}
					else{
						alert(result.message);
					}
				}
			});
			
		});
		
		$("textarea[name='msg_box']").bind("keydown",function(e){
			if(!is_email){
				checkInvMsgLen(".sms-box",0);
			}
			else{
				checkInvMsgLen(".email-box",1);
			}
		});
		
		$("#ct_close_btn").click(function(){
			$("#contacter-tmpbox").addClass("hide");
		});
		
		$("#ct_close_btn").click(function(){
			$("#contacter-tmpbox").addClass("hide");
		});
		
		$("#ct_submit_btn").click(function(){
			if($.trim($("#contacter-tmpbox input[name='user_name']").val())==""){
				alert("请输入姓名");
				$("#contacter-tmpbox input[name='user_name']").focus();
				return false;
			}
			if($.trim($("#contacter-tmpbox input[name='tel']").val())=="" && $.trim($("#contacter-tmpbox input[name='email']").val())==""){
				alert("请输入手机号或E-mail");
				return false;
			}
			if($.trim($("#contacter-tmpbox input[name='tel']").val())!=""){
				if(!$.checkMobilePhone($.trim($("#contacter-tmpbox input[name='tel']").val()))){
					alert("您好，您的手机号格式不正确!");
					return false;
				}
			}
			if($.trim($("#contacter-tmpbox input[name='email']").val())!=""){
				if(!$.checkEmail($.trim($("#contacter-tmpbox input[name='email']").val()))){
					alert("您好，您的邮箱格式不正确!");
					return false;
				}
			}
			var query = $("#contacter-tmpbox form").serialize();
			$.ajax({
				url:APP_ROOT + "/index.php?ctl=uc_contacter&act=do_contacter&is_ajax=1",
				data:"&"+query,
				type:"post",
				dataType:"json",
				success:function(result){
					if(result.status==1){
						$("#contacter-tmpbox input[name='user_name']").val("");
						$("#contacter-tmpbox input[name='tel']").val("");
						$("#contacter-tmpbox input[name='email']").val("");
						$("#ct_info_id").val(0);
						if($("#ct_is_close").attr("checked")==true){
							$("#contacter-tmpbox").addClass("hide");
						}
						$("#invAlertBox .contact .c-box").load(APP_ROOT + "/store.php?ctl=order&act=get_contacter&is_ajax=1&is_email="+is_email,"",function(){
							checkContactLi();
						});
						
					}
					else{
						alert(result.message);
					}
				}
			});
		});
	});
	function setEditBox(){
		$("input[name='tmpEdit']").focus();
		$("input[name='tmpEdit']").bind("blur",function(){
			var obj = $(this);
			var html = $.trim(obj.val());
			if (html != "") {
				if (html.indexOf(";") == -1) {
					html += ";";
				}
			}
			var idx = obj.attr("data-index");
			obj.parent().find("span").each(function(){
				if (html != "") {
					if ($(this).attr("data-index") == idx) {
						$(this).html(html);
						$(this).show();
					}
				}
				else{
					if ($(this).attr("data-index") == idx) {
						$(this).remove();
					}
				}
			});
			obj.remove();
			if (is_email) {
				checkSpan("#invEmailListBox", 1);
			}
			else {
				checkSpan("#invTelListBox", 0);
			}
			is_click_edit = false;
		});
		$("input[name='tmpEdit']").bind("keydown",function(e){
			var key = e.which;
            if (key == 13) {
				var obj = $(this);
				var html = $.trim(obj.val());
				if(html!=""){
					if (html.indexOf(";") == -1) {
						html += ";";
					}
				}
				var idx = obj.attr("data-index");
				obj.parent().find("span").each(function(){
					if (html != "") {
						if ($(this).attr("data-index") == idx) {
							$(this).html(html);
							$(this).show();
						}
					}
					else{
						if ($(this).attr("data-index") == idx) {
							$(this).remove();
						}
					}
				});
				obj.remove();
				if (is_email) {
					checkSpan("#invEmailListBox", 1);
				}
				else {
					checkSpan("#invTelListBox", 0);
				}
				is_click_edit = false;
			}
			
		});
		
		$("input[name='tmpEdit']").click(function(){
			is_check = true;
			$(this).parent().parent().addClass("res_inv_invter_area_cur");
			$("#invTelListBox span,#invEmailListBox span").removeClass("focus");
			if (!is_check) {
				$(this).parent().parent().find("input[name='invIptBox']").focus();
			}
			return false;
		});
	}
	
	function checkSpan(obj,is_sms){
		var idx = 0;
		$(obj).find("span").each(function(){
			var val = $(this).html().replace(";","");
			if(is_sms==0){
				if(!$.checkMobilePhone($.trim(val))){
					$(this).addClass("err");
				}
				else{
					$(this).removeClass("err");
				}
			}
			else{
				if(!$.checkEmail($.trim(val))){
					$(this).addClass("err");
				}
				else{
					$(this).removeClass("err");
				}
			}
			$(this).attr("data-index",idx);
			idx++;
		});
		initClickFunc();
	}
	function initClickFunc(){
		$("#invTelListBox span").click(function(){
			is_check = true;
			$(this).parent().parent().addClass("res_inv_invter_area_cur");
			$("#invTelListBox span").removeClass("focus");
			$(this).addClass("focus");
			if (!is_check) {
				$("#invTelListBox span").removeClass("focus");
				$(this).parent().parent().find("input[name='invIptBox']").focus();
			}
			return false;
		});
		$("#invEmailListBox span").click(function(){
			is_check = true;
			$(this).parent().parent().addClass("res_inv_invter_area_cur");
			$("#invEmailListBox span").removeClass("focus");
			$(this).addClass("focus");
			if (!is_check) {
				$("#invEmailListBox span").removeClass("focus");
				$(this).parent().parent().find("input[name='invIptBox']").focus();
			}
			return false;
		});
		$("#invTelListBox span,#invEmailListBox span").dblclick(function(){
			if (!is_click_edit) {
				var w = $(this).outerWidth();
				$(this).before("<input type='text' style='width:" + w + "px' name='tmpEdit' data-index='" + $(this).attr("data-index") + "' value='" + $(this).html() + "'/>");
				$(this).hide();
				setEditBox();
				is_click_edit = true;
			}
		});
		$("#invTelListBox span,#invEmailListBox span").hover(function(){
			$(this).addClass("cur");
		},function(){
			$(this).removeClass("cur");
		});
	}
	var tmpl_area_val = "";
	function checkInvMsgLen(obj,is_sms){
		var val = $.trim($(obj).find("textarea[name='msg_box']").val());
		var max_len = 0;
		var len = getLen(val);
		if(is_sms==0)
		{
			max_len = 160;
		}
		else{
			max_len = 2000;
		}
		if(len > max_len){
			alert("输入的内容必须小于"+max_len+"个字符");
			$(obj).find("textarea[name='msg_box']").val(tmpl_area_val);
			return false;
		}
		tmpl_area_val = $.trim($(obj).find("textarea[name='msg_box']").val());
		$("#invCurrentLetters").html(len);
		$("#invTotalLetters").html(max_len);
	}
	function getLen(s){
		var l = 0;
		var a = s.split("");
		for (var i=0;i<a.length;i++) {
			if(a[i].charCodeAt(0)<299){
				l++;
			} else {
				l+=2;
			}
		}
		return l; 
	}
	
	function ViewContactBox(obj,id){
		$("#contacter-tmpbox input[name='user_name']").val("");
		$("#contacter-tmpbox input[name='tel']").val("");
		$("#contacter-tmpbox input[name='email']").val("");
		$("#ct_info_id").val(0);
		$("#ct_is_close_tip").html("新建成功后关闭该弹出框");
		if(id > 0)
		{
			$.ajax({
				url:APP_ROOT + "/index.php?ctl=uc_contacter&act=modify&is_ajax=1&id="+id,
				type:"post",
				dataType:"json",
				success:function(result){
					if(result.status==1){
						$("#contacter-tmpbox input[name='user_name']").val(result.info.user_name);
						$("#contacter-tmpbox input[name='tel']").val(result.info.tel);
						$("#contacter-tmpbox input[name='email']").val(result.info.email);
						$("#ct_info_id").val(result.info.id);
						$("#ct_is_close_tip").html("编辑成功后关闭该弹出框");
					}
				}
			});
		}
		if($("#contacter-tmpbox").hasClass("hide"))
			$("#contacter-tmpbox").removeClass("hide");
		else
			$("#contacter-tmpbox").addClass("hide");
	}
	
	function setContact(obj){
		if(!is_email){
			var is_v = false;
			var tel=$(obj).attr("tel");
			if($("#invTelListBox span").length > 0){
				$("#invTelListBox span").each(function(){
					var spanval=$(this).html().replace(";","");
					if(spanval==tel){
						$(this).remove();
						is_v=true;
					}
				});
			}
			if(!is_v){
				$("#invTelListBox").html($("#invTelListBox").html()+"<span>"+tel+";</span>");
				checkSpan("#invTelListBox",0);
			}
		}
		else{
			var is_v = false;
			var email=$(obj).attr("email");
			if($("#invEmailListBox span").length > 0){
				$("#invEmailListBox span").each(function(){
					var spanval=$(this).html().replace(";","");
					if(spanval==email){
						$(this).remove();
						is_v=true;
					}
				});
			}
			
			if(!is_v && email!=""){
				$("#invEmailListBox").html($("#invEmailListBox").html()+"<span>"+email+";</span>");
				checkSpan("#invEmailListBox",1);
			}
		}
		checkContactLi();
	}
	function delContact(id){
		if(confirm("确定删除吗")){
			$.ajax({
				url:APP_ROOT + "/index.php?ctl=uc_contacter&act=del&is_ajax=1&id="+id,
				type:"post",
				dataType:"json",
				success:function(result){
					if(result.status==1){
						$("#invAlertBox .contact .c-box").load(APP_ROOT + "/store.php?ctl=order&act=get_contacter&is_ajax=1&is_email="+is_email,"",function(){
							checkContactLi();
						});
					}
					else{
						alert(result.message);
					}
				}
			});
		}
	}
	
	function checkContactLi(){
		$("#invTelListBox span").each(function(){
			var spanval=$(this).html().replace(";","");
			$("#invAlertBox .contact .c-box li .v").each(function(){
				if(spanval==$(this).attr("tel")){
					$(this).css({"color":"green"});
				}
				else{
					$(this).css({"color":"#333"});
				}
			});
		});
		$("#invEmailListBox span").each(function(){
			var spanval=$(this).html().replace(";","");
			$("#invAlertBox .contact .c-box li .v").each(function(){
				if(spanval==$(this).attr("email")){
					$(this).css({"color":"green"});
				}
				else{
					$(this).css({"color":"#333"});
				}
			});
		});
	}
</script>
